home *** CD-ROM | disk | FTP | other *** search
- /* fclosall.c --- p 404 */
- #include <stdio.h>
- main()
- {
- int i;
- /* Try opening 20 temporary files -- we'll just throw
- * away the returned pointers because we are not going
- * to use these files. The file open will fail after 15
- * files are opened. So the number of closed files
- * should be 15. */
- for (i=0; i < 20; i++)
- {
- if (tmpfile() == NULL)
- printf ("Error opening file # %d\n", i);
- else
- printf ("Temporary file #%d opened\n", i);
- }
- /* Now closed all the files and inform user how many were
- * closed */
- i = fcloseall();
- printf("%d files were closed -- should be 15\n", i);
- }